//
//  RegisteredServiceVC.m
//  reSearchDemo
//
//  Created by 科技 on 15/7/29.
//  Copyright (c) 2015年 Kiwaro. All rights reserved.
//

#import "RegisteredServiceVC.h"
#import "NextRegisteredVC.h"
@interface RegisteredServiceVC ()

@end

@implementation RegisteredServiceVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setRightBarButtonImage:LOADIMAGE(@"btn_more") highlightedImage:nil selector:@selector(menu)];
    
    UIView *actionbar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, 44)];
    self.navigationItem.titleView = actionbar;
    UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(8, 0, 100, 40)];
    lab.text = @"申请服务商";
    lab.font = [UIFont systemFontOfSize:20];
    lab.textColor = [UIColor whiteColor];
    [actionbar addSubview:lab];

    [self AllocView];
}
#pragma mark -
#pragma mark --初始化视图--
-(void)AllocView {
    UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(20, 84, CGRectGetWidth(self.view.frame) - 40, 200)];
    textView.backgroundColor = [UIColor lightGrayColor];
    textView.editable = NO; //禁止编辑
    textView.autoresizingMask = UIViewAutoresizingFlexibleHeight;//自适应高度
    [self.view addSubview:textView];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(CGRectGetMinX(textView.frame) + 20, CGRectGetMaxY(textView.frame)+ 10, 20, 20);
    btn.selected = NO;
    [btn setImage:[UIImage imageNamed:@"btn_radio_n@2x"] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:@"btn_radio_s@2x"] forState:UIControlStateSelected];
    [btn addTarget:self action:@selector(selectBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
    UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(btn.frame) + 10, CGRectGetMinY(btn.frame) + 2, 200, 20)];
    textLabel.text = @"同意本协议并申请";
    textLabel.font = [UIFont systemFontOfSize:13];
    textLabel.textColor = [UIColor blackColor];
    [self.view addSubview:textLabel];
    
    UIButton *nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    nextBtn.tag = 1000;
    nextBtn.frame = CGRectMake(CGRectGetMinX(btn.frame), CGRectGetMaxY(btn.frame) + 30, CGRectGetWidth(textView.frame) - 40, 40);
    nextBtn.selected = NO;
    [nextBtn setBackgroundColor:[UIColor lightGrayColor]];
    [nextBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [nextBtn setTitle:@"下一步 申请服务商" forState:UIControlStateNormal];
    [nextBtn setTitle:@"下一步 申请服务商" forState:UIControlStateSelected];
    [nextBtn addTarget:self action:@selector(NextBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:nextBtn];
}

#pragma mark -
#pragma mark --点击响应方法--
//导航栏右按钮响应方法
-(void)menu{
    
}
//同意按钮响应方法
-(void)selectBtnAction:(UIButton *)sender {
    UIButton *btn = (UIButton *)[self.view viewWithTag:1000];
    if (sender.selected) {
        sender.selected = NO;
        btn.selected = NO;
        btn.backgroundColor = [UIColor lightGrayColor];
    }else {
        sender.selected = YES;
        btn.selected = YES;
        btn.backgroundColor = [UIColor greenColor];
    }
}
//下一步按钮响应方法
-(void)NextBtnAction:(UIButton *)sender {
    if (!sender.selected) {
        return;
    }else {
        [self pushViewController:[NextRegisteredVC new]];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
